<template>
	<view>
		<custom-nav
			:isBar="true"
			:isShowLogo="true"
			:isShowBottom="companyList.length > 1 ? true : false"
			:title="
				selectedCompany &&
				selectedCompany.tenantName &&
				selectedCompany.tenantName.length > 10
					? `${selectedCompany.tenantName.slice(0, 8)}...`
					: selectedCompany.tenantName
			"
			:isBack="false"
			@switch="switchCompany"
		></custom-nav>
		<view>
			<diy-empty></diy-empty>
		</view>
		<selectedCompany-popup
			:isShow="isShowSwitchCompany"
			:companyList="companyList"
			@selectedItem="selectedItem"
			@close="closeSwitchCompany"
			:selectedCompany="selectedCompany"
		>
		</selectedCompany-popup>
		<!-- <custom-tabbar :pagePath="pagePath" /> -->
	</view>
</template>
<script>
import selectedCompanyPopup from '@/components/selected-company/selected-company.vue'
import diyEmpty from '@/components/diy-empty/diy-empty.vue'
export default {
	components: { selectedCompanyPopup, diyEmpty },
	data() {
		return {
			pagePath: '/pages/circle/index',
			companyList: [],
			selectedCompany: {},
			isShowSwitchCompany: false,
		}
	},
	onLoad() {
		this.companyList = uni.getStorageSync('companyList')
	},
	onShow() {
		this.companyList = uni.getStorageSync('companyList')
		this.selectedCompany = uni.getStorageSync('selectedCompany')
		console.log(this.selectedCompany, '---this.selectedCompany---------')
	},
	methods: {
		switchCompany() {
			this.isShowSwitchCompany = true
		},
		closeSwitchCompany() {
			this.isShowSwitchCompany = false
		},
		selectedItem(val) {
			this.selectedCompany = val
			uni.setStorageSync('selectedCompany', val)
			uni.setStorageSync('orgId', val.tenantId)
			this.closeSwitchCompany()
		},
	},
}
</script>
<style lang="scss" scoped></style>
